package com.cloud.lan.api;

import com.cloud.lan.api.dto.req.BaseReq;
import com.cloud.lan.api.dto.req.LanMpUserReq;
import com.cloud.lan.api.dto.req.WxLoginRequest;
import com.cloud.lan.api.dto.resp.LanUserResp;
import com.cloud.lan.entity.base.BaseResponse;
import com.cloud.lan.service.ILanUserService;
import com.cloud.lan.service.ILanWxMpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping(value = {"/v1/mp/user/api/"}, method = {RequestMethod.GET, RequestMethod.POST}, consumes = {"*/*"}, produces = {"application/json"})
public class LanMpUserApi {
    @Resource
    ILanWxMpService lanWxMpService;
    @Resource
    ILanUserService lanUserService;

    @RequestMapping("checkMpUser")
    public BaseResponse<Object> checkMpUser(@RequestHeader(BaseReq.ut) String token) {
        LanUserResp lanUserResp = lanUserService.getUserInfo(token);
        log.info("unionId：" + lanUserResp.getUnionId());
        return lanWxMpService.getMpUser(lanUserResp.getUnionId());
    }
}
